<template>
  <view class="footprint">
    <view class="main"  v-for="(item, index) in initData" :key="index">
      <view class="list">
        <view class="time">{{item.time}}</view>
        <view class="list-li">
          <view class="shop"  @click="go_goods(item)">
            <view class="img">
				  <image :src="imgCDNUrl+item.imgs" mode="widthFix">
            </view>
            <view class="msg">
              <view class="name">{{item.goodsName}}</view>
			  <view class="price">
				  <text>￥{{item.discountPrice}}</text>
                <!-- <image
                  src="/static/img/car_1.png"
                  class="right"
                /> -->
              </view>
            </view>
          </view>
        </view>
      </view>
      <view class="cut-off"></view>
    </view>
  </view>
</template>
<script>
import { uniIcons } from '@dcloudio/uni-ui';
import footprint from '../../../servers/my/footprint.js';	
export default {
	components: { uniIcons },
	data() {
		return {
			initData: [],
			compile: false,
			is_go_top: false,
			delArray:[],
			is_all: false,
			paging: {
				page: 1,
				total: 100
			}
		};
	},
	onPageScroll: function(e) {
		//nvue暂不支持滚动监听，可用bindingx代替
		if (e.scrollTop > 200) {
			this.is_go_top = true;
		} else {
			this.is_go_top = false;
		}
	},
	mounted() {
		var footprint = uni.getStorageSync('footprint')
		this.initData = footprint
		// this.getDate();
	},
	methods: {
		
		getDate() {
			var obj={currentPage:this.paging.page, pageSize: 10}
			footprint.initData(obj)
				.then(res => {
					this.paging.total=Math.ceil(res.data.total/res.data.size); 
					this.initData = res.data.records.map(v => {
						v.vo=v.vo.map(v1 => {
						v1.image = this.imgCDNUrl + v1.goodsImg;
						return v1;
					});
					return v
					});
					
				})
				.catch(err => {
					console.log(new Error('请检查网络后重试'));
				});
				
		},
		all(e) {
			if (this.is_all) {
				this.is_all = false;
				for (var i = 0; i < this.shop_list.length; ++i) {
					const item = this.shop_list[i];
					this.$set(item, 'checked', false);
				}
			} else {
				this.is_all = true;
				for (var i = 0; i < this.shop_list.length; ++i) {
					const item = this.shop_list[i];
					this.$set(item, 'checked', true);
				}
			}
		},
		backTop() {
			uni.pageScrollTo({
				scrollTop: 0,
				duration: 200
			});
		},
		checkboxChange(e) {
			var items = this.shop_list,
				values = e.detail.value;
				
			for (var i = 0; i < items.length; ++i) {
				const item = items[i];
				if (values.includes(String(i))) {
					this.$set(item, 'checked', true);
				} else {
					this.$set(item, 'checked', false);
				}
			}
			if (items.length == values.length) {
				this.is_all = true;
			} else {
				this.is_all = false;
			}
			console.log(this.shop_list);
		},
		next() {
			if (this.paging.page < this.paging.total) {
				this.paging.page += 1;
				this.getDate();
			}
		},
		prev() {
			if (this.paging.page > 1) {
				this.paging.page -= 1;
				this.getDate();
			}
		},
		go_goods(e){
			if(e.actId!=0){
				this.commonality.route_balings('/pages/shop/commodity/particulars',['actId','shopId'],[e.actId,e.goodsId])
			}else{
				uni.removeStorageSync('actId');
				this.commonality.route_baling('/pages/shop/commodity/particulars','shopId',e.goodsId)
			}
		}
	}
};
</script>

<style lang="less" scoped>
.footprint {
  height: 100%;
  .main {
    // position: absolute;
    // top: 80rpx;
    // bottom: 0;
    // width: 100%;
    overflow: auto;
    .list {
      background: #fff;
      .time {
        line-height: 100rpx;
        font-size: 34rpx;
        border-bottom: 1rpx solid #e1e1e1; /*no*/
        padding: 0 20rpx;
      }
      .list-li {
        padding: 0 20rpx;
        .shop {
          display: flex;
          border-bottom: 1rpx solid #e1e1e1; /*no*/
          padding: 39rpx 0 33rpx;
          .img{
            image {
              width: 218rpx;
              height: 218rpx;
              border-radius: 20rpx;
            }
          }
          .msg {
            position: relative;
            padding-left: 29rpx;
            width: 100%;
            .name {
              font-size: 30rpx;
              line-height: 50rpx;
              overflow: hidden;
              text-overflow: ellipsis;
              display: -webkit-box;
              -webkit-box-orient: vertical;
              -webkit-line-clamp: 2;
            }
            .price {
              position: absolute;
              width: 100%;
			  right: 0;
              bottom: 0;
              color: #bd3c8c;
              font-size: 34rpx;
			  padding-left: 29rpx;
			  box-sizing: border-box;
              text {
                font-size: 30rpx;
              }
              .right {
                width: 44rpx;
                height: 44rpx;
                position: relative;
                right: 40rpx;
                top: -5rpx;
              }
            }
          }
        }
      }
      .list-li:nth-last-child(1) {
        .shop {
          border-bottom: none;
        }
      }
    }
  }
}
</style>
